--PROCEDURE AND VIEW VACANCY

--CREAET VIEW SelectElementTypeJob
GO
CREATE VIEW SelectElementTypeJob
AS
SELECT * FROM tb_TypeJob
--CREATE VIEW VacancyIDLast
GO
CREATE VIEW VacancyIDLast
AS
SELECT tb_Vacancy.VacancyID FROM tb_Vacancy
--CREATE PROCEDURE InsertTableVacancy
GO
CREATE PROCEDURE InsertTableVacancyNew
@VacancyID		VARCHAR(10),
@Title			VARCHAR(100),
@JobID			INT,
@UserName		VARCHAR(10),
@Description	NVARCHAR(1000),
@NumberOfJob	SMALLINT,
@Salary			VARCHAR(20),
@Workplace		VARCHAR(100),
@DateCreatioin	DATETIME,
@DateFulfilled	DATETIME,
@Status			SMALLINT
AS
INSERT INTO tb_Vacancy VALUES(@VacancyID, @Title, @JobID, @UserName, @Description, @NumberOfJob, @Salary, @Workplace, @DateCreatioin, @DateFulfilled, @Status)
--CREATE PROCEDURE ReturnVacancyOfUserName
GO
CREATE PROCEDURE ReturnVacancyOfUserName
@UserName		VARCHAR(10)
AS
SELECT tb_Vacancy.VacancyID, tb_Vacancy.Title FROM tb_Vacancy WHERE UserName = @UserName
--CREATE PROCEDURE ReturnApplicantOfVacancy
GO
CREATE PROCEDURE ReturnApplicantOfVacancy
@VacancyID		VARCHAR(10)
AS
SELECT tb_Applicant.FullName, tb_Applicant.ApplicantID  FROM tb_Applicant WHERE VacancyID = @VacancyID
--CREATE VIEW ReturnInterviewer
GO
CREATE VIEW ReturnInterviewer
AS
SELECT tb_Interviewer.FullName, tb_Interviewer.InterViewerID FROM tb_Interviewer
--CREATE PROCEDURE InsertIntoTableInterview
GO
CREATE PROCEDURE InsertIntoTableInterview
@InterviewerID		VARCHAR(10),
@VacancyID			VARCHAR(10),
@ApplicantID		VARCHAR(10),
@Date				DATETIME,
@Time				VARCHAR(10),
@Status				SMALLINT
AS
INSERT INTO tb_Interview VALUES(@InterviewerID, @VacancyID, @ApplicantID, @Date, @Time, @Status)
--CREATE PROCEDURE ReturnNameEmployee
GO
CREATE PROCEDURE ReturnNameEmployee
@UserName			VARCHAR(10)
AS
SELECT tb_Employee.FullName FROM tb_Employee WHERE UserName = @UserName
--CREATE VIEW ReturnTypeJob
GO 
CREATE VIEW ReturnTypeJob
AS
SELECT tb_TypeJob.JobID, tb_TypeJob.JobName FROM tb_TypeJob
--CREATE PROCEDURE ReturnVacancyFollowTypeJob
GO
CREATE PROCEDURE ReturnVacancyFollowTypeJob
@ID					INT
AS
SELECT tb_Vacancy.VacancyID, tb_Vacancy.Title FROM tb_Vacancy WHERE JobID = @ID
--CREATE PROCEDURE ReturnApplicantFollowTypeJob
GO
CREATE PROCEDURE ReturnInterviewFollowTypeJob
@ID					INT
AS
SELECT tb_Vacancy.VacancyID, tb_Vacancy.Title FROM tb_Vacancy WHERE JobID = @ID